<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String contextPath = request.getContextPath();
%> 
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>후ㅡ기</title>
<style type="text/css">
	#board_wrap{
		margin-left: 30px;
		margin-top: 30px;
		padding: 0;
		font-family: Verdana;
		font-size: 12px;
		color: #696969;
		line-height: normal;
		font-style: normal;
	}
	#board_middle{
		margin-left: 30px;
		margin-right: 200px;
		float: left;
		
	}
	#board_head{
		width: 699px;
		text-align: left;
	}
	#info_table{
		border-spacing: 2px;
		border-color: gray;
		border-collapse: collapse;
		width:699px;
		text-align: left;
	}
	#info_table th{
		width: 150px;
		height:20px;
		text-align: center;
		background:#fff2e2; 
		padding: 10px 0 10px 0px;
		font-weight: bold;
		border-bottom: 2px solid white;
	}
	#info_table td{
		text-align: left;
		padding: 10px 10px 10px 30px;
	}
	#board_bottom{
		margin-top: 3px;
	}
	#btn_write{
		width: 650px;
		text-align: center;
	}
	.list_button, .list_button2{
		width: 130px;
		height: 30px;
		background-color: #2F4F4F;
		font-family: "맑은 고딕";
		font-size: 9pt;
		color: white;
		border: 0;
		border-radius:5px;
	}
	.list_button2{
		margin-left: 15px;
	}
	.write_button{
		margin-left:20px;
		width: 130px;
		height: 30px;
		background-color: #0d836b;
		font-family: "맑은 고딕";
		font-size: 9pt;
		color: white;
		border: 0;
		border-radius:5px;
	}
	#board_image{
		max-width: 500px;
	}
	#board_wrap{
		margin-left: 30px;
		margin-top: 30px;
		padding: 0;
		font-family: Verdana;
		font-size: 12px;
		color: #696969;
		line-height: normal;
		font-style: normal;
	}
	#board_center{
		width: 699px;
		margin-right: 10px;
	}
	#content_table th{
		font-weight: bold;
		background:#fff2e2; 
		text-align:center; 
		padding:10px 0 10px 0; 
		border-top:1px solid #e0e0e0;
		width: 120px;
		height: 25px;
	}
	#content_table{
		float: left;
		margin-top: 20px;
	}
	#content_table td{
		height:20px;
		font-size: 11px;
		text-align: center;
		border-bottom:1px solid #d3ccbe; 
		padding:10px 0; 
		cursor: default;
	}
	#content_table a{
		text-decoration: none;
		color: #696969;
		cursor: pointer;
	}
	#content_table a:hover{
		color:red; 
		font-weight: bold;
	}
	.search{
		margin: 0 auto;
	}
	.inputb{
		border-bottom: #999999 1px solid;
		border-left: #cecece 1px solid;
		border-right: #999999 1px solid;
		border-top: #cecece 1px solid;
		color: #000000;
		font-size: 9pt;
		background-color: #ededed;
		width:50px;
		height:25px;
	}
	.align-right{
		text-align: right;
	}
	#delbutton{
		border-bottom: #999999 1px solid;
		border-left: #cecece 1px solid;
		border-right: #999999 1px solid;
		border-top: #cecece 1px solid;
		color: #000000;
		font-size: 9pt;
		background-color: #ededed;
		width: 50px;
		height: 25px;
		text-align: center;
		padding:0 0 0 0;
	}
	#mile_btn{
		margin-left:15px;
		width: 130px;
		height: 30px;
		font-family: "맑은 고딕";
		font-size: 9pt;
		color: white;
		border: 0;
		border-radius:5px;
		background-color:#993B3B; 
	}
	
</style>
<script type="text/javascript">
function board_del(){
	document.getElementById('delete_div').setAttribute('style', 'display: block;');
}
function cancle(){
	document.getElementById('delete_div').setAttribute('style', 'display: none;');
}
function board_mile(){
	document.getElementById('board_mile').setAttribute('style', 'display: block;');
}


</script>

</head>
<body>
<div id="board_wrap">
	<div id="board_head" >
		<p>
			<img src="./images/board/title_review_4.png">
		</p>
	</div>
	<div id="board_middle">
		<table id="info_table">
			<tr>
				<th>작 성 자</th>
				<td>${boardCommand.writer}</td>
			</tr>
			<tr>
				<th>매 장</th>
				<td>${boardCommand.branch_name}</td>
			</tr>
			<tr>
				<th>제 목</th>
				<td>${boardCommand.board_title}</td>
			</tr>
			<tr>
				<th>후 기</th>
				<td height="300px;" style="padding-bottom: 50px;">
				<c:if test="${!empty boardCommand.filename}">
				<img src="./upload/${boardCommand.filename}" id="board_image">
				</c:if>
				<br>
				${boardCommand.board_content}</td>
			</tr>
		</table>
		<br><br>
	<div id="btn_write" style="height: 130px;">
		<c:if test="${member_name == boardCommand.writer}">
			<input type="button" value="목록으로" class="list_button" style="cursor: pointer;" onclick="location.href='boardList.do'">
			<input type="button" value="후기수정" class="list_button2" onclick="location.href='<%=contextPath %>/modify.do?board_num=${boardCommand.board_num}'" style="cursor: pointer;">
			<input type="button" value="후기삭제" class="list_button2" onclick="board_del()" style="cursor: pointer;">
			<form action="boardDelete.do" method="post">
				<div id="delete_div" style="display: none;">
				<br><br>
					<span style="font-weight: bold; color: red; width: 650px; text-align: center;">정말 삭제할까요?&nbsp;&nbsp;</span>
					<input type="hidden" name="board_num" value="${boardCommand.board_num}">
					<input type="submit" id="delbutton" value="삭제">
					<input type="button" id="delbutton" value="취소" onclick="cancle()">
				</div>
			</form>
		</c:if>
		<c:if test="${member_email=='admin'}">
			<form action="boardMile.do" method="post">
				<input type="button" value="목록으로" class="list_button" style="cursor: pointer;" onclick="location.href='boardList.do'">
				<input type="button" value="후기삭제" class="list_button2" onclick="board_del()" style="cursor: pointer;">
				<input type="submit" value="적립" id="mile_btn" style="cursor: pointer;">
				<input type="hidden" name="board_num" value="${boardCommand.board_num}">
				<input type="hidden" name="writer" value="${boardCommand.writer}">
			</form>
			<form action="boardDelete.do" method="post">
				<div id="delete_div" style="display: none;">
				<br><br>
					<span style="font-weight: bold; color: red; width: 650px; text-align: center;">정말 삭제할까요?&nbsp;&nbsp;</span>
					<input type="hidden" name="board_num" value="${boardCommand.board_num}">
					<input type="submit" id="delbutton" value="삭제">
					<input type="button" id="delbutton" value="취소" onclick="cancle()">
				</div>
			</form>
		</c:if>
	</div>
	</div>
	<div id="board_wrap">
		<div id="board_center">
			<div id="main_contents">
				<table id="content_table">
					<tbody>
						<tr>
							<th>NO</th>
							<th>매장명</th>
							<th style="width:230px;">TITLE</th>
							<th>작 성 자</th>
							<th>DATE</th>
						</tr>
						<c:forEach var="article" items="${boardList}">
						<c:if test="${article.board_num == boardCommand.board_num}">
						<tr style="color: blue; font-weight: bold;">
							<td>
								${article.board_num}
							</td>
							<td>
								${article.branch_name}
							</td>
							<td>
								<c:if test="${article.filename != null}">
								${article.board_title}&nbsp;&nbsp;<img src="./images/board/image.png" width="5%">
								</c:if>
								
								<c:if test="${article.filename == null}">${article.board_title}</c:if>
							</td>
							<td>${article.writer}</td>
							<td>${article.regdate}</td>
						</tr>
						</c:if>
						<c:if test="${article.board_num != boardCommand.board_num }">
						<tr>
							<td>
								${article.board_num}
								
							</td>
							<td>
								${article.branch_name}
							</td>
							<td>
								<input type="hidden" name="board_num" value="${boardCommand.board_num}">
								
								<c:if test="${article.filename != null}">
								<a href="<%=contextPath %>/view.do?board_num=${article.board_num}">${article.board_title}</a>&nbsp;&nbsp;<img src="./images/board/image.png" width="5%">
								</c:if>
								
								<c:if test="${article.filename == null}">
								<a href="<%=contextPath %>/view.do?board_num=${article.board_num}">${article.board_title}</a>
								</c:if>
							</td>
							<td>${article.writer}</td>
							<td>${article.regdate}</td>
						</tr>
						</c:if>
						</c:forEach>
						<c:if test="${count == 0}">
						<tr>
							<td colspan="5" class="align-center">등록된 게시물이 없습니다.</td>
						</tr>	
						</c:if>
					</tbody>
				</table>
			</div>
			<div>
			<form action="writeForm.do" method="POST">
			<input type="hidden" name="email" value="${email}">
				<table style="width: 699px;">
					<c:if test="${count > 0}">
					<tr>
						<td class="align-center" style="text-align: center;" height="30px;">${pagingHtml}</td>
					</tr>
					</c:if>
					<c:if test="${!empty email}">
						<tr>
							<td style="text-align: right;">
								<input type="submit" value="글쓰기" class="inputb">
							</td>
						</tr>
					</c:if>
				</table>
			</form>
			<p style="height: 20px"></p>
			</div>
		</div>
	</div>
	

</div>
</body>
</html>